package com.joysuch.wwyt.app.service.impl;

import com.joysuch.wwyt.app.service.AppInspectService;
import com.joysuch.wwyt.bp.bean.inspect.BpInspectRecordQueryBean;
import com.joysuch.wwyt.bp.entity.inspect.BpInspectRecord;
import com.joysuch.wwyt.bp.service.BpInspectPlanService;
import com.joysuch.wwyt.bp.service.BpInspectRecordService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author ZhangDong
 * @Date 2020/6/24 15:13
 */
@Service
@Slf4j
public class AppInspectServiceImpl implements AppInspectService {

    @Autowired
    private BpInspectPlanService bpInspectPlanService;
    @Autowired
    private BpInspectRecordService bpInspectRecordService;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public ResultBean appNeedDo(Pageable pageable) {
        return bpInspectPlanService.appNeedDo(pageable);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public ResultBean page(BpInspectRecordQueryBean bean) {
        Page<BpInspectRecord> page = bpInspectRecordService.list(bean, 1);
        return ResultBean.pageData(page.getContent(), page.getTotalElements());
    }

    @Override
    public ResultBean get(Long planId) {
        return bpInspectPlanService.appGetByPlanId(planId);
    }
}
